<?php
require_once("util/DButil.php");
// 默认值
$pageNum = 1;
if(isset($_REQUEST["pageNum"])) {
    // 有此参数时, 使用给定的值
    $pageNum = $_REQUEST["pageNum"];
}
$pageSize = 2;

// 查询可供分页使用的总数据量
$sql = "select count(1) count from t_product where p_status = 1";
$products = query($sql);
// 总数据量
$count = $products[0]["count"];
// 总页数
$totalPage = ceil($count/$pageSize);

$m = ($pageNum - 1) * $pageSize;
$n = $pageSize;

// 查询当页的数据·
$sql = "select p_id, p_name, p_price, p_unit, p_image_url, p_status from t_product where p_status = 1 limit {$m}, {$n}";

$productArr = query($sql);

?>